package org.jeecg.common.Wechat.util;

import java.io.InputStream;
import java.util.Properties;

/**
 * Created by conan on 2017/4/26.
 */
public class WeiXinConFig {
    private static WeiXinConFig instance = null;

    private Properties properties = null;

    private WeiXinConFig() {
        init();
    }

    public static WeiXinConFig getInstance() {

        if (instance == null) {
            instance = new WeiXinConFig();
        }
        return instance;
    }

    /**
     * 初始化配置文件
     */
    public void init() {
        try {
            InputStream is = WeiXinConFig.class
                    .getResourceAsStream("/com/lwsoft/weixin/res/wei-xin.properties");
            properties = new Properties();
            properties.load(is);

        } catch (Exception e) {
            throw new RuntimeException("Failed to get properties!");
        }
    }
    /**
     * 根据key值取得对应的value值
     *
     * @param key
     * @return
     */
    public String getValue(String key) {
        return properties.getProperty(key);
    }

    /**
     * @return the properties
     */
    public Properties getProperties() {
        return properties;
    }
}
